#!/bin/sh
#
# /usr/share/live-helper/hooks/stripped - hook list for live-helper(7)
# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org>
#
# live-helper comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
# This is free software, and you are welcome to redistribute it
# under certain conditions; see COPYING for details.
# 
# 2009, 2010 Iwan Setiawan <stwn at kuliax.org>

set -e

# Removing unused packages
for PACKAGE in aptitude cpp-4.1 diffstat dselect ed gcc-4.1-base gcc-4.1 \
gcc-4.2-base gwenview-i18n info nano tasksel tasksel-data tcpd \
openoffice.org-filter-binfilter openoffice.org-java-common openoffice.org-style-crystal \
usplash-theme-debian
do
	if ! apt-get remove --purge --yes "${PACKAGE}"
	then
		echo "WARNING: ${PACKAGE} isn't installed"
	fi
done

# apt-get autoremove --yes || true
apt-get -y install deborphan

# Removing unused files
find . -name *~ | xargs rm -f

# rm -rf /usr/include/*
# rm -rf /usr/share/groff/*

#cp -r /usr/share/doc/cnet/ /home/lumpia/
#cp -r /usr/share/doc/live-initramfs/ /home/lumpia/
#rm -rf /usr/share/doc/*
#mv /home/lumpia/cnet/ /usr/share/doc/
#mv /home/lumpia/live-initramfs/ /usr/share/doc/

# rm -rf /usr/share/locale/*
# rm -rf /usr/share/man/*
# rm -rf /usr/share/i18n/*
rm -rf /usr/share/info/*
rm -rf /usr/share/lintian/*
rm -rf /usr/share/linda/*

#cp -r /usr/share/zoneinfo/Asia/ /home/lumpia/
#cp -r /usr/share/zoneinfo/UTC /home/lumpia/
#rm -rf /usr/share/zoneinfo/*
#mv /home/lumpia/Asia/ /usr/share/zoneinfo/
#mv /home/lumpia/UTC /usr/share/zoneinfo/
rm -rf /var/cache/man/*

# Truncating logs
for FILE in $(find /var/log/ -type f)
do
	: > ${FILE}
done

# Cleaning apt lists
rm -rf /var/lib/apt/lists
mkdir -p /var/lib/apt/lists/partial

# Cleaning apt cache
rm -rf /var/cache/apt
mkdir -p /var/cache/apt/archives/partial

for i in 1 2 3
do
	deborphan | xargs apt-get remove --purge -y
done

apt-get -y remove --purge deborphan

rm /etc/resolv.conf*
echo "" > /etc/resolv.conf

rm -rf /usr/src/*.deb
#rm /usr/src/linux-OLDVERSION*
rm -rf /usr/src/modules/
